package com.xvheng.module.merchantApi.service.impl;

import java.util.List;
import com.xvheng.common.utils.DateUtils;
import com.xvheng.common.utils.IdGen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xvheng.module.merchantApi.mapper.MerchantMapper;
import com.xvheng.module.merchantApi.domain.Merchant;
import com.xvheng.module.merchantApi.service.IMerchantService;

/**
 * 商户Service业务层处理
 * 
 * @author xvheng
 * @date 2024-06-21
 */
@Service
public class MerchantServiceImpl implements IMerchantService 
{
    @Autowired
    private MerchantMapper merchantMapper;

    /**
     * 查询商户
     * 
     * @param ID 商户主键
     * @return 商户
     */
    @Override
    public Merchant selectMerchantByID(String ID)
    {
        return merchantMapper.selectMerchantByID(ID);
    }

    /**
     * 查询商户列表
     * 
     * @param merchant 商户
     * @return 商户
     */
    @Override
    public List<Merchant> selectMerchantList(Merchant merchant)
    {
        merchant.setDR("0");
        return merchantMapper.selectMerchantList(merchant);
    }

    /**
     * 新增商户
     * 
     * @param merchant 商户
     * @return 结果
     */
    @Override
    public int insertMerchant(Merchant merchant)
    {
        merchant.setID(IdGen.uuid());
        merchant.setCreateTime(DateUtils.getNowDate());
        return merchantMapper.insertMerchant(merchant);
    }

    /**
     * 修改商户
     * 
     * @param merchant 商户
     * @return 结果
     */
    @Override
    public int updateMerchant(Merchant merchant)
    {
        merchant.setUpdateTime(DateUtils.getNowDate());
        return merchantMapper.updateMerchant(merchant);
    }

    /**
     * 批量删除商户
     * 
     * @param IDs 需要删除的商户主键
     * @return 结果
     */
    @Override
    public int deleteMerchantByIDs(String[] IDs)
    {
        return merchantMapper.deleteMerchantByIDs(IDs);
    }

    /**
     * 删除商户信息
     * 
     * @param ID 商户主键
     * @return 结果
     */
    @Override
    public int deleteMerchantByID(Long ID)
    {
        return merchantMapper.deleteMerchantByID(ID);
    }
}
